package com.hospital.data.simulation.controller;

import com.hospital.common.base.Result;
import com.hospital.common.pojo.TUser;
import com.hospital.data.simulation.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理接口
 * @author yhn
 * @version 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private TUserService userService;

    /**
     * 添加用户
     * @return 添加的用户ID
     */
    @PostMapping("/add")
    public Result<Long> addUser(@RequestBody TUser user){
        return Result.success(userService.addUser(user));
    }
    /**
     * 删除用户
     * @param id 用户ID
     */
    @DeleteMapping("/delete")
    public Result<?> deleteUser(@RequestParam("id") Long id){
        userService.deleteUser(id);
        return Result.success();
    }

    /**
     * 更新用户
     * <br>
     * 需要提供用户ID
     */
    @PostMapping("/update")
    public Result<?> updateUser(@RequestBody TUser user){
        userService.updateUser(user);
        return Result.success();
    }
}
